//2810. 故障键盘

#include <algorithm>
#include <string>
using namespace std;

class Solution {
public:
    string finalString(string s) {
        string str;
        for(auto ch : s)
        {
            if(ch == 'i')
            {
                reverse(str.begin(), str.end());
            }
            else
            {
                str.push_back(ch);
            }
        }
        return str;
    }
};